package com.cj.display_sys.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.cj.display_sys.R
import com.cj.display_sys.http.Picture
import com.cj.display_sys.utils.showImg
import kotlinx.android.synthetic.main.item_image.view.*

class ImageAdapter :
    BaseQuickAdapter<Picture, BaseViewHolder>(R.layout.item_image) {

    override fun convert(helper: BaseViewHolder, item: Picture) {
        helper.itemView.apply {
            iv_banner_img.showImg(item.pictureURL)
        }
    }

    override fun getItemCount(): Int {
        return Int.MAX_VALUE
    }


    override fun getItem(position: Int): Picture {
        return data[position % data.size]
    }

    override fun getItemViewType(position: Int): Int {
        var count = headerLayoutCount + data.size
        if (count <= 0) {
            count = 1
        }
        return super.getItemViewType(position % count)
    }

}